home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1988 June / Ahoy_Magazine_88-06_1988_Double_L.d64 / Directory Scan (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  4KB  |  128 lines

  1. 0 rem << rr54-1 >>
  2. 1 rem===================================
  3. 2 rem
  4. 3 rem       directory  scanner
  5. 4 rem
  6. 5 rem       rupert report #54
  7. 6 rem
  8. 7 rem==== c-64/128 ==== 1541/1571 ======
  9. 8 print""
  10. 10 rem
  11. 20 rem  read and display directory
  12. 30 rem  using dos direct access commands
  13. 40 rem
  14. 100 gosub 1000      :rem initialize
  15. 110 open 15,dvc,15  :rem command channel
  16. 120 gosub 7000    :rem check disk status
  17. 130 :rem   open data channel 2; set up a disk buffer for it
  18. 140 open 1,dvc,2,"#"
  19. 150 gosub 7000    :rem check disk status
  20. 160 :rem -- read sector into channel 2's  buffer in disk drive :
  21. 170 print# 15,rd$;2;dvc;tk;sc
  22. 180 gosub 7000    :rem check disk status
  23. 190 gosub 2000     :rem read disk buffer into computer
  24. 200 :rem -- interpret data bytes --
  25. 210 for fil=0 to 7
  26. 220 gosub 3000 :rem display dir entries
  27. 230 rem >>> gosub 5000 :rem select undeletion
  28. 240 next fil
  29. 250 print l$
  30. 260 rem >>>> if udflg then goto 6000:rem undelete & end
  31. 270 gosub 4000 :rem continue or end?
  32. 280 goto 170   :rem continue
  33. 290 rem --------------------------------
  34. 1000 rem ========  initialize  =========
  35. 1010 print chr$(147); "==directory scanner==": print
  36. 1020 false=0: true=not false: z$=chr$(0)
  37. 1030 nul$=z$: sp$="  ": l$="--"
  38. 1040 for n=1 to 4: nul$=nul$+nul$: sp$=sp$+sp$: l$=l$+l$: next
  39. 1050 sp$="[145]  " + sp$ + "  [145]"
  40. 1060 for n=0 to 4: read typ$(n): next n
  41. 1070 data del, seq, prg, usr, rel
  42. 1080 rd$="u1": wr$="u2"
  43. 1090 tk=18: sc=1 :rem 1st dir trk/sector
  44. 1100 dvc=8
  45. 1110 return
  46. 1120 rem -------------------------------
  47. 2000 rem ========  read sector =========
  48. 2010 b$=""
  49. 2020 print "reading track, sector :"; tk; sc
  50. 2030 print "================================="
  51. 2040 print "file name.......type:  tk sc  len"
  52. 2050 print "================================="
  53. 2060 print# 15,"b-p";2;0   :rem point to byte 0 of chnl 2 buffer
  54. 2065 :rem get next dir track & sector
  55. 2070 get# 1,tk$: if tk$="" then tk$=z$
  56. 2080 get# 1,sc$: if sc$="" then sc$=z$
  57. 2090 for n=2 to 255
  58. 2100 get# 1,d$
  59. 2110 if d$="" then d$=z$
  60. 2120 b$=b$+d$   :rem read buffer into b$
  61. 2130 next n
  62. 2140 return
  63. 2150 rem -------------------------------
  64. 3000 rem =======  interpret data  ======
  65. 3010 ptr=fil*32+1
  66. 3020 ff=asc(mid$(b$,ptr,1))    :rem file status
  67. 3030 md=ff and 192     :rem closure mode
  68. 3040 typ=ff and 7      :rem file type
  69. 3050 :rem -- first tk & sector of file
  70. 3060 ftk=asc(mid$(b$,ptr+1,1))
  71. 3070 fsc=asc(mid$(b$,ptr+2,1))
  72. 3080 nm$=mid$(b$,ptr+3,16) :rem filename
  73. 3090 nulflg=false: if nm$=nul$ then nm$="( unused entry )": nulflg=true
  74. 3100 blk=asc(mid$(b$,ptr+28,1))+asc(mid$(b$,ptr+29,1))*256 :rem file length
  75. 3110 print nm$;: if nulflg then print: goto 3130
  76. 3120 print ","; typ$(typ); ": "; ftk; fsc; blk
  77. 3130 if md=192 then print "      ( file locked )"
  78. 3140 if md=0 and typ>0 then print "> file not properly closed <"
  79. 3150 return
  80. 3160 rem -------------------------------
  81. 4000 rem =======  continue  ============
  82. 4010 print: print "q to quit; any other key to continue"
  83. 4020 get k$: if k$>"" then 4020     :rem empty kybd buffer
  84. 4030 get k$: if k$="" then 4030
  85. 4040 print sp$
  86. 4050 if k$="q" then 4100
  87. 4060 rem -- next track & sector of dir :
  88. 4070 tk=asc(tk$+z$): sc=asc(sc$+z$)
  89. 4080 if tk=18 then goto 4110
  90. 4090 print "no more files in directory"
  91. 4100 close 1: close 15: end
  92. 4110 return
  93. 4120 rem -------------------------------
  94. 5000 rem ==== select for undeletion ====
  95. 5010 if typ>0 or nulflg then 5100
  96. 5020 print " press u to undelete this file[146]"
  97. 5030 get k$: if k$>"" then 5030:     rem clear kybd
  98. 5040 get k$: if k$="" then 5040
  99. 5050 print sp$:if k$<>"u" then goto 5100
  100. 5060 udflg=true : ct=ct+1
  101. 5070 print "[145]"; tab(35); "*"
  102. 5080 print "  (- to be undeleted -)"
  103. 5090 b$=left$(b$,ptr-1)+chr$(128+2)+mid$(b$,ptr+1)
  104. 5100 return
  105. 5110 rem -------------------------------
  106. 6000 rem ========= undelete ============
  107. 6010 print# 15,"b-p";2;0
  108. 6020 print# 1,tk$;sc$;b$;
  109. 6030 gosub 7000
  110. 6040 print# 15,wr$;2;dvc;tk;sc
  111. 6050 gosub 7000
  112. 6060 print# 15,"v0"  :rem validate
  113. 6070 print "validating disk..."
  114. 6080 gosub 7000
  115. 6090 print ct; "file(s) undeleted"
  116. 6100 close 1: close 15: end
  117. 6110 rem -------------------------------
  118. 7000 rem ======  check disk status  ====
  119. 7010 if ds$="" then goto 7050  :rem (for c-64 only)
  120. 7020 if ds<20 then return
  121. 7030 print "disk error :"; ds$ : close 1: close 15: end
  122. 7040 rem === c-64 only ===
  123. 7050 input# 15,en,em$,et,es
  124. 7060 if en<20 then return
  125. 7070 print "disk error :"; en;em$;et;es
  126. 7080 close 1: close 15: end
  127. 7090 rem -------------------------------
  128.